package org.javaboy.webflux_r2dbc.route;

import org.javaboy.webflux_r2dbc.handler.UserHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.server.*;

@Configuration
public class RouterConfiguration {

    @Bean
    RouterFunction<ServerResponse> userRouterFunction(UserHandler userHandler) {
        return RouterFunctions.nest(RequestPredicates.path("/user"),RouterFunctions.route(RequestPredicates.GET(""),userHandler::getUser).andRoute(RequestPredicates.POST(""),userHandler::addUser));
    }
}
